package cn.hexcloud.dga.common.util;

import com.squareup.okhttp.Call;
import com.squareup.okhttp.OkHttpClient;
import com.squareup.okhttp.Request;
import com.squareup.okhttp.Response;

import java.io.IOException;
import java.math.BigDecimal;

/**
 * @author q1603
 * 用于返回url请求的数据
 */
public class HttpUtil {
    private static OkHttpClient client = getInstance();

    private static OkHttpClient getInstance() {
        return new OkHttpClient();
    }

    public static String get(String url) {
        Request request = new Request.Builder().get().url(url).build();

        Call call = client.newCall(request);
        try {
            Response response = call.execute();
            String respString = response.body().string();
            return respString;
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    public static void main(String[] args) {
        System.out.println(HttpUtil.get("http://hadoop102:18080/api/v1/applications/application_1682383663913_0018/1/stages/0"));

    }
}
